package com.king.demo.config;

import com.king.demo.annotions.InterNo;

import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class ServiceProxy<T> implements InvocationHandler, Serializable {
    private final Class<T> interfaces;

    public ServiceProxy(Class<T> mapperInterface) {
        this.interfaces = mapperInterface;
    }

    @Override
    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
        InterNo annotation = method.getAnnotation(InterNo.class);
        if (annotation == null){
            throw new Exception("该方法未暴露");
        }
        String name = annotation.name();
        System.out.println("Proxy invoker run .........");
        System.out.println("name:" + name);
        return null;
    }
}
